<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        body{
            width: 100%;
            height: 100%;
            background-color: #59375A;
        }
        #login{
            top: 50%;
            left: 50%;
            margin-top: -100px;
            margin-left:-200px ;
            position: absolute;
        }
        #login .login_info{
            display: flex;
            width: 400px;
            height: 50px;
            background-color: #6D4A70;
            color: #ffffff;
            font-size: 36px;
            font-weight: bold;
        }
        #login #form{
            width: 400px;
            background-color:#F2F2F2 ;
        }
        #login input{
            width:330px;
            height: 30px;
            border:1px solid black;
            border-radius: 5px;
            margin-top:  35px;
            margin-left: 35px;
            margin-buttom:10px;
            padding: 10px;
            box-sizing: border-box;
            background-repeat: no-repeat;
            background-size:22px;
            background-position:300px;
        }

        #login  button{
            width: 60px;
            height: 30px;
            font-size:16px;
            cursor: pointer;
            border: 1px solid black;
            border-radius: 5px;
            margin-top: 15px;
            margin-left: 25px;
            margin-bottom: 30px;
            text-align:center;
            background-color: #59375A;
            color: #ffffff;
        }
        #login #footer a{
            text-decoration: none;
        }
    </style>
</head>
<body>
<div id="login" >
    <div class="login_info">
        <p>Login Form &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;×</p>

    </div>
    <form action="" method="GET"  id="form">
        <table>
            <tr>
                <td>

                    <input type="text" name="user_name" id="user_name" onblur="checkUserName()" placeholder="请输入账号"
                     style="background-image: url('img/ic_input_name.png' ) " required pattern="^[0-9][a-zA-Z0-9]{5,11}$">
                </td>

            </tr>
            <tr>
                <td>

                        <input type="password" name="user_pwd" id="user_pwd" onblur="checkPwd()" placeholder="请输入密码"
                         style="background-image: url('img/ic_input_password.png')" required pattern="^[0-9a-zA-Z]{6，12}$">
                </td>
            </tr>
        </table>
        <div id="footer">
            <button type="submit" >
                Sign in
            </button>
            <a href="">Lost your Password ？</a>
        </div>
    </form>
</div>
<script type="text/javascript">

    function checkUserName() {
        var name = document.getElementById("user_name").value;
        var reg = /^[0-9][a-zA-Z0-9]{5,11}$/;
        var flag = false;
        if (reg.test(name)) {
            flag = true;
        }
        return flag;
    }
    function checkPwd(){
        var pwd = document.getElementById("user_pwd").value;
        var reg = /^[0-9a-zA-Z]{6，12}$/;
        var flag = false;
        if(reg.test(pwd)){
            flag = true;
        }
        return flag;
    }
    document.getElementById("form").onsubmit=function(){
        return checkUserName() && checkPwd();
    }
</script>
</body>
</html>